#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<vector>
#include<cmath>
#include"Newton.h"

using namespace std;

class function2 :public Function
{
public:
	double operator()(double x)
	{
		return 1 / (1 + 25 * x * x);
	}
};


int main()
{
	function2 f;
	cout << "-----------------C----------------" << endl;
	for (int n = 5;n <= 20;n = n + 5)
	{
		vector<double> x;
		for (double i = 0;i <= n;i++)
		{
			double x1 = cos((2 * i + 1) * M_PI / (2 * n));
			x.push_back(x1);
		}
		vector<double> y;
		for (int i = 0;i <= n;i++)
		{
			double y1 = f(x[i]);
			y.push_back(y1);
		}
		Newton N(x, y);
		cout << "当n=" << n << "时:" << endl;
		N.output();
		cout << endl << endl;

     ofstream mcfile("C.txt",ios::app|ios::out);
        for(int i=0;i<n;i++)
        {
            mcfile << x[i] << "," << N.getTable(i,i) << endl;
        }
        mcfile.close();
	}
	return 0;
}